import { useContext, useEffect, useState } from 'react';
import { SearchOutlined, EyeOutlined, QuestionCircleOutlined } from '@ant-design/icons';
import { TagSelectNew } from '@/components/TagSelectNew';
import { UploadFormCommon } from '@/components/UploadForm';
import { ContractManageAPI } from '../common/type';
import {
  getLoadMapList,
  getTenantID,
  getUserDepName,
  getFileNameByPath,
  getUserDepID,
  renderTableTextNotColor,
  getSelectDataMapList,
  getCompanyID,
  getPosIDs,
  getUserID,
  getUserName,
  getUserShortCode,
  getCurrentPosInfo,
  getKeyRouter,
  getCompanyName,
  getPosName,
  wordHandChildParamContract,
} from '@/utils';
import { ILoadMapTypeAll } from '@/common';
import { useDescriptionsType } from '@/components/DescriptionsType';
import { UpdateCounterpartView } from '../mview/UpdateCounterpartView';
import { UpdateMaterialTableView } from '../mview/UpdateMaterialTableView';
import { UpdatePaymentView } from '../mview/UpdatePaymentView';
import { UpdateFiledTableView } from '../mview/UpdateFiledTableView';
import { ConractControllerContext, IContractsActionEnum } from '../common';
import { RegularExpression } from '@/common/constVariable';
import moment from 'moment';
import { Form, Input, Slider, Tooltip, TreeSelect, message, Select, AutoComplete } from 'antd';
import { handleNotPostion, changeContractSumList } from './useMyUtil';
import { getFlowOrgTreeByOrgIDService, getUserDataList } from '@/services/BaseLayout';
import { UpdateFirstPartyTableView } from '../mview/UpdateFirstPartyTableView';
import { FormOutlined } from '@ant-design/icons';

const getDescrConfig = ({
  openApplyModal,
  openTempModalFunc,
  openSubjectModal,
  changeTextInfo,
  onFormChange,
  onNtkoReadWord,
  onOpenReadOfdWord,
  openCounterpartModal,
  updateForm,
  setOpenMaterialModal,
  setProjectModal,
  enterPurchProject,
}: // setOpenOwnerDeptModal,
ContractManageAPI.IUpdateDesConfig) => {
  /** 获取上下文 */
  const { pageType, contractForm, contractDetailInfo, locationState, contractDispatch, contarctJsonList, counterpartRows } =
    useContext(ConractControllerContext);

  /**  获取数据字典 */
  const { loadMapInfo, mapLoading } = getLoadMapList([
    `${getTenantID()}${ILoadMapTypeAll.PAYMENT_STYLE}`, //支付方式
    `${getTenantID()}${ILoadMapTypeAll.COMPANY_TAXRATE}`, //税率
    `${getTenantID()}${ILoadMapTypeAll.CONTRACT_FIELDTYPE}`, //合同附件类型
    // `${getTenantID()}${ILoadMapTypeAll.MATERIAL_MIDI}`, //量化单位
    `${getTenantID()}${ILoadMapTypeAll.CONTRACT_TYPE}`, // 合同类型
    `${getTenantID()}${ILoadMapTypeAll.CONTRACT_STATE}`, // 合同状态
    `${getTenantID()}${ILoadMapTypeAll.PURCHASE_METHOD}`,
    `${getTenantID()}${ILoadMapTypeAll.PURCHASE_CATEGORY}`, //供货类别
    `${getTenantID()}${ILoadMapTypeAll.MATERIAL_MIDI}`, //量化单位
    // `${getTenantID()}${ILoadMapTypeAll.MATERIAL_BRAND}`, //品牌
    `${getTenantID()}${ILoadMapTypeAll.CONTRACT_CURRENCYTYPE}`, //币种
  ]);

  /** 保存支付方式 */
  const [paymentType, setPaymentType] = useState<string>(contractDetailInfo?.payStyle || '');

  /** 保存预计开始时间 */
  const [preBeginTimeStart, setPreBeginTimeStart] = useState<any>();

  /** 保存币种类型 */
  const [currencyType, setCurrencyType] = useState<any>();

  useEffect(() => {
    if (contractDetailInfo?.preBeginTime) {
      setPreBeginTimeStart(moment(contractDetailInfo?.preBeginTime));
    }
  }, [contractDetailInfo?.preBeginTime]);

  /** 处理税率对象 */
  const taxRateInfoHand = () => {
    let taxRateInfo: Record<string, any> = {};
    loadMapInfo?.[`${getTenantID()}${ILoadMapTypeAll.COMPANY_TAXRATE}`]?.forEach((item: any) => {
      if (item?.name) {
        taxRateInfo[Number(item?.name)] = item?.name;
      }
    });
    return taxRateInfo;
  };

  /** 合同类型 */
  const businessTypeList = getSelectDataMapList(loadMapInfo?.[`${getTenantID()}${ILoadMapTypeAll.CONTRACT_TYPE}`], 'name', 'id', true);

  /** 获取业务部门数据 */
  const { getFlowOrgTreeRun, getFlowOrgTreeLoading, getFlowOrgList } = getFlowOrgTreeByOrgIDService();

  /** 获取当前部门用户数据 */
  const { getUserRun, getUserLoading, getUserList } = getUserDataList((res: any) => {
    if (!(res && res?.msgFlag)) {
      message.error(res?.msg);
    }
  });

  useEffect(() => {
    getFlowOrgTreeRun({
      //获取组织机构信息
      params: 0,
      flowType: 'null',
    });

    getUserRun({
      //获取当前部门用户信息
      userDepartmentID: getUserDepID(),
    });
  }, []);

  // const deptTreeList = handleNotPostion(getLevelFirstJson())

  /** 处理合同状态 */
  // const stateName = useMemo(() => {
  //   if (contractDetailInfo && contractDetailInfo?.stateName) {
  //     return getColorTextLoadMap(contractDetailInfo?.stateName)?.colorText;
  //   } else {
  //     return '起草';
  //   }
  // }, [contractDetailInfo]);

  const getShortCode = (id, contractForm) => {
    let shortCode = '';
    const setShortCode = (children) => {
      (children || []).forEach((item) => {
        if (item?.id == id) {
          shortCode = item.shortCode;
        } else {
          if (item.children && item.children?.length) setShortCode(item.children);
        }
      });
    };
    setShortCode(loadMapInfo?.[`${getTenantID()}${ILoadMapTypeAll.CONTRACT_TYPE}`]);
    contractForm?.setFieldsValue({
      contractTypeCode: shortCode,
    });

    return shortCode;
  };

  /** 表单配置 */
  const [config, methods] = useDescriptionsType({
    labelWidth: 190,
    basicForm: updateForm ? updateForm : contractForm,
    name: 'contract-addAndEdit',
    schemas: [
      {
        key: 'contract-basic',
        title: '基本信息',
        titleAfter: (
          <span>
            {/* <MyIcon type="icon-dian" isTheme={false} />
            {stateName} */}
          </span>
        ),
        fieldChildren: [
          {
            field: `contractName`,
            label: `合同名称`,
            component: 'InputTextArea',
            placeholder: '请输入',
            required: pageType == 'detail' ? false : true,
            disabled: pageType == 'detail' ? true : false,
            autoSize: { minRows: 1, maxRows: 3 },
          },
          {
            field: `contractCode`,
            label: `合同编号`,
            component: 'Input',
            disabled: locationState?.updateType == 'UpdateRepairAdd' ? false : true,
            required: locationState?.updateType == 'UpdateRepairAdd' ? true : false,
            placeholder: pageType == 'detail' ? '自动带出' : locationState?.updateType == 'UpdateRepairAdd' ? '请输入' : '自动带出',
            pattern: RegularExpression?.numberOrLetter,
            patternMsg: '请输入数字或英文',
          },
          {
            field: 'contractTypeCode',
            label: '合同类型编码',
            component: 'Input',
            placeholder: '请输入',
            disabled: true,
            colSpan: 2,
            initialValue: getShortCode(contractDetailInfo?.businessType, contractForm),
            display: 'none',
          },
          {
            field: `businessType`,
            label: `合同类型`,
            component: 'Render',
            placeholder: '请选择',
            required: pageType == 'detail' ? false : true,
            options: businessTypeList,
            render: (text) => {
              // let codeLast: string = '';
              // if (contractDetailInfo?.id) {
              //   codeLast = contractDetailInfo?.contractCode?.substring(10);
              // }
              return (
                <TreeSelect
                  loading={mapLoading}
                  disabled={pageType == 'detail' ? true : false}
                  showArrow={pageType == 'detail' ? false : true}
                  placeholder="请选择"
                  treeData={businessTypeList}
                  fieldNames={{
                    label: 'name',
                    value: 'value',
                    children: 'children',
                  }}
                  showSearch={true}
                  treeNodeFilterProp={'name'}
                  onSelect={(_value, node) => {
                    if (node?.pID) {
                      contractForm?.setFieldsValue({
                        pbusinessType: node?.pID,
                        businessTypeName: node?.name,
                        // 合同类型上级
                        // draftCode: str,
                        // contractCode: str,
                        contractTypeCode: node?.shortCode,
                      });
                      // }
                    }
                  }}
                />
              );
            },
          },
          {
            field: `contractNum`,
            label: `合同份数`,
            component: 'InputNumber',
            placeholder: '请输入',
            required: pageType == 'detail' ? false : true,
            disabled: pageType == 'detail' ? true : false,
            min: 1,
            contentAfter: '份',
            initialValue: '1',
            pattern: RegularExpression?.number,
            patternMsg: '请输入整数',
          },
          {
            field: `ownDepartmentName`,
            label: `申请部门`,
            component: 'Input',
            disabled: true,
            // required: pageType == 'detail' ? false : true,
            placeholder: '自动带出',
            message: '请选择申请部门',
            initialValue: getUserDepName(),
            // contentAfter: pageType == 'detail'  ? null : (
            //   <a
            //     onClick={() => {
            //       setOpenOwnerDeptModal({
            //         isShowModal: true,
            //         checkTypeInfo: checkContractTypeInfo
            //       });
            //     }}
            //   >
            //     <SearchOutlined />
            //   </a>
            // ),
          },
          {
            field: `ownerName`,
            label: `申请人`,
            component: 'Input',
            placeholder: '自动带出',
            disabled: true,
            // required: pageType == 'detail' ? false : true,
            message: '请选择申请人',
            initialValue: getUserName(),
          },
          {
            field: `busiDepartmentID`,
            label: `业务归口部门`,
            component: 'Render',
            disabled: true,
            message: '请选择业务归口部门',
            placeholder: '请选择',
            render: (text) => {
              if (pageType == 'detail') {
                return <span>{contractDetailInfo?.busiDepartmentName || '--'}</span>;
              } else {
                return (
                  <TreeSelect
                    loading={getFlowOrgTreeLoading}
                    placeholder="请选择"
                    treeData={handleNotPostion(getFlowOrgList)}
                    disabled={pageType == 'detail' ? true : false}
                    showArrow={pageType == 'detail' ? false : true}
                    fieldNames={{
                      label: 'title',
                      value: 'id',
                      children: 'children',
                    }}
                    showSearch={true}
                    treeNodeFilterProp={'text'}
                    allowClear={true}
                    onSelect={(_value, node) => {
                      if (node) {
                        contractForm?.setFieldsValue({
                          busiDepartmentName: node?.text,
                        });
                        // }
                      }
                    }}
                  />
                );
              }
            },
          },
          {
            field: `relateDepartmentID`,
            label: `相关部门`,
            component: 'Render',
            disabled: true,
            message: '请选择相关相关部门',
            placeholder: '请选择',
            render: (text) => {
              if (pageType == 'detail') {
                return <span>{contractDetailInfo?.relateDepartmentName || '--'}</span>;
              } else {
                return (
                  <TreeSelect
                    loading={getFlowOrgTreeLoading}
                    placeholder="请选择"
                    treeData={handleNotPostion(getFlowOrgList)}
                    disabled={pageType == 'detail' ? true : false}
                    showArrow={pageType == 'detail' ? false : true}
                    fieldNames={{
                      label: 'title',
                      value: 'id',
                      children: 'children',
                    }}
                    showSearch={true}
                    treeNodeFilterProp={'text'}
                    allowClear={true}
                    onSelect={(_value, node) => {
                      if (node) {
                        contractForm?.setFieldsValue({
                          relateDepartmentName: node?.text,
                        });
                        // }
                      }
                    }}
                  />
                );
              }
            },
          },
          {
            field: `projectName`,
            label: `预算项目`,
            component: 'Input',
            placeholder: '自动带出',
            disabled: true,
            required: pageType == 'detail' ? false : true,
            contentAfter: contractForm.getFieldValue('purchProjectName') ? null : (
              <a>
                {' '}
                <SearchOutlined onClick={setProjectModal} />
              </a>
            ),
          },
          {
            field: `projectCode`,
            label: `预算项目编号`,
            component: 'Input',
            placeholder: '自动带出',
            disabled: true,
            required: pageType == 'detail' ? false : true,
          },
          {
            field: `capitalDir`,
            label: `资金流向`,
            component: 'Render',
            required: pageType == 'detail' ? false : true,
            initialValue: 0,
            render: (text: string | number) => {
              if (pageType == 'detail') {
                return (
                  <Form.Item name="capitalDir" style={{ cursor: 'not-allowed' }}>
                    {text == 0 ? '付款' : text == 1 ? '收款' : text == 2 ? '无金额' : ''}
                  </Form.Item>
                );
              } else {
                return (
                  <TagSelectNew
                    formLabel=""
                    formName="capitalDir"
                    formRequired={pageType == 'detail' ? false : true}
                    radioDisabled={pageType == 'detail' ? true : false}
                    radioList={[
                      {
                        name: '付款',
                        value: 0,
                      },
                      {
                        name: '收款',
                        value: 1,
                      },
                      {
                        name: '无金额',
                        value: 2,
                      },
                    ]}
                    onChange={(value: string | number) => {
                      if (value == 2) {
                        contractForm?.setFieldsValue({
                          sumInTax: 0,
                          payStyle: `${getTenantID()}${ILoadMapTypeAll.PAYMENT_STYLE}1002`,
                          taxRate: '0',
                          sumInTaxCN: '零',
                          capitalDir: value,
                          payStyleName: '其他方式',
                        });
                        setPaymentType(`${getTenantID()}${ILoadMapTypeAll.PAYMENT_STYLE}1002`);
                      } else {
                        contractForm?.setFieldsValue({
                          payStyle: null,
                          taxRate: null,
                          capitalDir: value,
                          payStyleName: '',
                        });
                        setPaymentType(contractForm?.getFieldValue('payStyle'));
                      }
                    }}
                    defalultKeys={text || 0}
                  />
                );
              }
            },
          },
          {
            field: `majorFlag`,
            label: `是否重大（要）合同`,
            required: pageType == 'detail' ? false : true,
            component: 'Render',
            initialValue: 0,
            render: (text) => {
              if (pageType == 'detail') {
                return (
                  <Form.Item name="majorFlag" style={{ cursor: 'not-allowed' }}>
                    {renderTableTextNotColor(text)}
                  </Form.Item>
                );
              } else {
                return (
                  <TagSelectNew
                    formLabel=""
                    formName="majorFlag"
                    formRequired={pageType == 'detail' ? false : true}
                    radioDisabled={pageType == 'detail' ? true : false}
                    radioList={[
                      {
                        value: 1,
                        name: '是',
                      },
                      {
                        value: 0,
                        name: '否',
                      },
                    ]}
                    defalultKeys={text || 0}
                  />
                );
              }
            },
          },
          {
            field: `currencyType`,
            label: `币种`,
            component: 'Select',
            placeholder: '请选择',
            required: pageType == 'detail' ? false : true,
            disabled: pageType == 'detail' ? true : false,
            showArrow: pageType == 'detail' ? false : true,
            options: loadMapInfo?.[`${getTenantID()}${ILoadMapTypeAll.CONTRACT_CURRENCYTYPE}`],
            initialValue: `${getTenantID()}${ILoadMapTypeAll.CONTRACT_CURRENCYTYPE}1000`,
            onChange: (value: string, option) => {
              if (value == `${getTenantID()}${ILoadMapTypeAll.CONTRACT_CURRENCYTYPE}1000`) {
                contractForm?.setFieldsValue({
                  currencyRate: 1,
                  currencyTypeName: option?.name,
                });
              } else {
                contractForm?.setFieldsValue({
                  currencyRate: undefined,
                  currencyTypeName: option?.name,
                });
              }
              setCurrencyType(value);
            },
            fieldNames: {
              label: 'name',
              value: 'id',
            },
          },
          {
            field: `currencyRate`,
            // label: `汇率`,
            label: (
              <>
                汇率&nbsp;
                <Tooltip title="外币/人民币">
                  <a>
                    <QuestionCircleOutlined />
                  </a>
                </Tooltip>
              </>
            ),
            component: 'InputNumber',
            placeholder: '请输入',
            required: pageType == 'detail' ? false : true,
            disabled:
              pageType == 'detail' || contractForm?.getFieldValue('currencyType') == `${getTenantID()}${ILoadMapTypeAll.CONTRACT_CURRENCYTYPE}1000`
                ? true
                : false,
            min: 0,
            initialValue: 1,
            pattern: RegularExpression?.currencyRate,
            patternMsg: '请输入正确汇率',
            step: '0.0001',
            message: '请输入汇率',
          },
          {
            field: `sumInTax`,
            // label: `合同金额（含税）`,
            label: (
              <>
                合同/框架金额（含税）&nbsp;
                <Tooltip title="若为框架合同，请填写框架总额；若为据实结算合同，请填写预估或暂定金额">
                  <a>
                    <QuestionCircleOutlined />
                  </a>
                </Tooltip>
              </>
            ),
            component: 'InputNumber',
            placeholder: '请输入',
            message: '请输入合同金额',
            required: pageType == 'detail' ? false : true,
            disabled: pageType == 'detail' || contractForm?.getFieldValue('capitalDir') == 2 ? true : false,
            min: 0,
            // initialValue: 0.0,
            contentAfter: '元',
            step: '0.0001',
            // pattern: RegularExpression?.two2FloatNumber,
            // patternMsg: '合同金额，最多四位小数',
            onChange: (e) => {
              changeContractSumList(contractForm, contractDispatch, contarctJsonList, `${getTenantID()}${ILoadMapTypeAll.PAYMENT_STYLE}`);
            },
            rules:
              pageType == 'detail'
                ? []
                : [
                    {
                      pattern: RegularExpression?.two2FloatNumber,
                      message: '合同金额，最多四位小数',
                    },
                  ],
          },

          {
            field: `sumInTaxCN`,
            label: `金额大写`,
            component: 'Input',
            placeholder: '自动带出',
            disabled: true,
            contentAfter: '元',
          },
          {
            field: `taxRate`,
            // label: `税率（%）`,
            label: (
              <>
                综合税率（%）&nbsp;
                <Tooltip title="税额/合同金额 x 100%">
                  <a>
                    <QuestionCircleOutlined />
                  </a>
                </Tooltip>
              </>
            ),
            component: 'Render',
            placeholder: '请选择或输入',
            required: pageType == 'detail' ? false : true,
            pattern: RegularExpression?.taxRate,
            patternMsg: '请输入正确税率',
            message: '请选择或输入',
            render: (text) => {
              if (pageType == 'detail') {
                return <Input disabled={true} />;
              } else {
                const marks = taxRateInfoHand();
                const arr: any = [];
                Object.keys(marks)?.length &&
                  Object.keys(marks).map((item) => {
                    arr.push({
                      label: item,
                      value: item,
                    });
                  });
                return (
                  <AutoComplete
                    options={arr}
                    placeholder="请选择或输入"
                    disabled={pageType == 'detail' || contractForm?.getFieldValue('capitalDir') == 2 ? true : false}
                  />
                );
              }
            },
          },
          {
            field: `payStyle`,
            label: `支付方式`,
            component: 'Select',
            placeholder: '请选择',
            required: pageType == 'detail' ? false : true,
            disabled: pageType == 'detail' || contractForm?.getFieldValue('capitalDir') == 2 ? true : false,
            showArrow: pageType == 'detail' ? false : true,
            options: loadMapInfo?.[`${getTenantID()}${ILoadMapTypeAll.PAYMENT_STYLE}`],
            onChange: (value: string) => {
              const contractAllNum: number = contractForm?.getFieldValue('sumInTax') ? contractForm?.getFieldValue('sumInTax') : 0;
              if (contractAllNum > 0) {
                setPaymentType(value);
                contractForm?.setFieldsValue({
                  payStyleName: `${getTenantID()}${ILoadMapTypeAll.PAYMENT_STYLE}1000`
                    ? '一次性支付'
                    : `${getTenantID()}${ILoadMapTypeAll.PAYMENT_STYLE}1001`
                    ? '分期支付'
                    : '其他方式',
                });
              } else {
                message.warning('请先输入合同金额！');
                contractForm?.setFieldsValue({
                  payStyle: null,
                  payStyleName: '',
                });
              }
            },
            fieldNames: {
              label: 'name',
              value: 'id',
            },
          },
          {
            field: `authName`,
            label: (
              <>
                授权代表&nbsp;
                <Tooltip title="如合同各方均无授权代表，请填写“无”；如合同任何一方有授权代表，需上传合同附件">
                  <a>
                    <QuestionCircleOutlined />
                  </a>
                </Tooltip>
              </>
            ),
            component: 'Input',
            required: pageType == 'detail' ? false : true,
            disabled: pageType == 'detail' ? true : false,
            placeholder: '请输入',
            message: '请输入授权代表',
            onBlur: (e) => {
              if (e?.target?.value && e?.target?.value != '无') {
                /**若授权代表不为无，则强制添加一项相关附件数据 */
                let attachList = contractForm?.getFieldValue('attachList');
                let arr = attachList?.filter((item) => item?.attachType == `${getTenantID()}${ILoadMapTypeAll.CONTRACT_FIELDTYPE}1007`);
                if (!arr?.length) {
                  const addItemObj: Record<string, any> = {
                    key: `filedTable-${getKeyRouter()}`,
                    modifyFlag: 0,
                    attachType: `${getTenantID()}${ILoadMapTypeAll.CONTRACT_FIELDTYPE}1007`,
                  };
                  let changeList: Record<string, any>[] = contarctJsonList?.['attachList']?.length > 0 ? contarctJsonList?.['attachList'] : [];
                  changeList?.push(addItemObj);
                  contractDispatch({
                    type: IContractsActionEnum.CONTRACT_JSONLIST,
                    payload: {
                      ...contarctJsonList,
                      attachList: changeList,
                    },
                  });
                  const nowFiledTable: Record<string, any>[] = attachList?.length > 0 ? attachList : [];
                  let newFiledList: Record<string, any>[] = [...nowFiledTable];
                  newFiledList?.push(addItemObj);
                  contractForm?.setFieldsValue({
                    attachList: newFiledList,
                  });
                }
              }
            },
          },
          {
            field: `authPhone`,
            label: ` 授权代表联系电话`,
            component: 'Input',
            required: false,
            disabled: pageType == 'detail' ? true : false,
            placeholder: pageType == 'detail' ? '--' : '请输入',
            pattern: RegularExpression.phone,
            patternMsg: '授权代表电话格式不正确',
          },
          {
            field: `contacterID`,
            label: `合同联系人`,
            component: 'Render',
            required: pageType == 'detail' ? false : true,
            showArrow: pageType == 'detail' ? false : true,
            render: (text) => {
              return (
                <Select
                  placeholder="请选择"
                  disabled={pageType == 'detail' ? true : false}
                  onSelect={(_selectKey: string, option: Record<string, any>) => {
                    contractForm?.setFieldsValue({
                      phoneMobile: option?.phoneMobile ? option?.phoneMobile : null,
                      contacterName: option?.realName,
                    });
                  }}
                  showSearch
                  loading={getUserLoading}
                  options={getUserList}
                  fieldNames={{ label: 'realName', value: 'id' }}
                  optionFilterProp="children"
                  filterOption={(input: string, option?: { label: string; value: string }) => {
                    return (option?.realName ?? '').includes(input);
                  }}
                />
              );
            },
          },
          {
            // field: `ownPhone`,
            field: `phoneMobile`,
            label: ` 合同联系人电话`,
            component: 'Input',
            required: pageType == 'detail' ? false : true,
            disabled: pageType == 'detail' ? true : false,
            placeholder: '请输入',
            pattern: RegularExpression.phone,
            patternMsg: '合同联系人电话格式不正确',
            // initialValue: getPersonalInfo()?.phoneMobile,
          },
          {
            field: `recordFlag`,
            label: `是否补录`,
            required: pageType == 'detail' ? false : true,
            component: 'Render',
            initialValue: locationState?.updateType != 'UpdateRepairAdd' ? 0 : 1,
            disabled: true,
            render: (text) => {
              if (pageType == 'detail') {
                return (
                  <Form.Item name="recordFlag" style={{ cursor: 'not-allowed' }}>
                    {renderTableTextNotColor(text)}
                  </Form.Item>
                );
              } else {
                return (
                  <TagSelectNew
                    formLabel=""
                    formName="recordFlag"
                    formRequired={pageType == 'detail' ? false : true}
                    radioDisabled={true}
                    radioList={[
                      {
                        value: 1,
                        name: '是',
                        disabled: true,
                      },
                      {
                        value: 0,
                        name: '否',
                        disabled: true,
                      },
                    ]}
                    defalultKeys={locationState?.updateType != 'UpdateRepairAdd' ? 0 : 1}
                  />
                );
              }
            },
          },
          {
            field: `periodNum`,
            label: (
              <>
                质保期&nbsp;
                <Tooltip title="若无质保期请填写 0">
                  <a>
                    <QuestionCircleOutlined />
                  </a>
                </Tooltip>
              </>
            ),
            component: 'InputNumber',
            message: '若无质保期请填写 0',
            placeholder: '质保期',
            required: pageType == 'detail' ? false : true,
            disabled: pageType == 'detail' ? true : false,
            initialValue: 0,
            contentAfter: '月',
            dependencies: ['realBeginTime', 'realFinishTime'],
            rules: [
              ({ getFieldValue }) => ({
                validator(_, value) {
                  if (!getFieldValue('realBeginTime') || !getFieldValue('realFinishTime')) {
                    return Promise.resolve();
                  }
                  if (value == 0 || value == null) {
                    return Promise.resolve();
                  }
                  if (
                    contractForm?.getFieldValue('recordFlag') == 1 &&
                    value > moment(getFieldValue('realFinishTime')).diff(moment(getFieldValue('realBeginTime')), 'months')
                  ) {
                    return Promise.reject(new Error('签订截止时间减签订开始时间得到的月份应大于等于质保期。'));
                  }
                  return Promise.resolve();
                },
              }),
            ],
          },
          {
            field: `preBeginTime`,
            label: `预计起始时间`,
            component: 'DatePicker',
            format: 'YYYY-MM-DD',
            placeholder: '请选择',
            required: pageType == 'detail' ? false : true,
            disabled: pageType == 'detail' ? true : false,
            onChange: (date: any) => {
              setPreBeginTimeStart(date);
            },
            ishidden: locationState?.updateType != 'UpdateRepairAdd' ? false : true,
            dependencies: ['preFinishTime'],
            rules: [
              ({ getFieldValue }) => ({
                validator(_, value) {
                  if (!getFieldValue('preFinishTime')) {
                    return Promise.resolve();
                  }

                  if (moment(value)?.isAfter(moment(getFieldValue('preFinishTime')))) {
                    return Promise.reject(new Error('预计起始时间不能晚于预计结束时间，请修改。'));
                  }
                  return Promise.resolve();
                },
              }),
            ],
          },
          {
            field: `preFinishTime`,
            label: `预计结束时间`,
            component: 'DatePicker',
            format: 'YYYY-MM-DD',
            placeholder: '请选择',
            required: pageType == 'detail' ? false : true,
            disabled: pageType == 'detail' ? true : false,
            disabledDate: (date: any) => {
              const currentDate: any = preBeginTimeStart ? preBeginTimeStart : date;
              return date && date < currentDate;
            },
            ishidden: locationState?.updateType != 'UpdateRepairAdd' ? false : true,
            dependencies: ['preBeginTime'],
            rules: [
              ({ getFieldValue }) => ({
                validator(_, value) {
                  if (!getFieldValue('preBeginTime')) {
                    return Promise.resolve();
                  }

                  if (moment(value)?.isBefore(moment(getFieldValue('preBeginTime')))) {
                    return Promise.reject(new Error('预计结束时间不能早于预计起始时间，请修改。'));
                  }
                  return Promise.resolve();
                },
              }),
            ],
          },
          {
            field: `realBeginTime`,
            label: `合同签订时间`,
            component: 'DatePicker',
            format: 'YYYY-MM-DD',
            placeholder: pageType == 'detail' ? '--' : '请选择',
            required: pageType == 'detail' || locationState?.updateType != 'UpdateRepairAdd' ? false : true,
            disabled: pageType == 'detail' || locationState?.updateType != 'UpdateRepairAdd' ? true : false,
            ishidden: pageType == 'detail' || locationState?.updateType == 'UpdateRepairAdd' ? false : true,
            dependencies: ['realFinishTime', 'periodNum'],
            rules: [
              ({ getFieldValue }) => ({
                validator(_, value) {
                  if (!getFieldValue('realFinishTime')) {
                    return Promise.resolve();
                  }

                  if (moment(value)?.isAfter(moment(getFieldValue('realFinishTime')))) {
                    return Promise.reject(new Error('合同签订时间不能晚于合同截止时间，请修改。'));
                  }
                  return Promise.resolve();
                },
              }),
            ],
          },
          {
            field: `realFinishTime`,
            label: `合同截止时间`,
            component: 'DatePicker',
            format: 'YYYY-MM-DD',
            placeholder: pageType == 'detail' ? '--' : '请选择',
            required: pageType == 'detail' || locationState?.updateType != 'UpdateRepairAdd' ? false : true,
            disabled: pageType == 'detail' || locationState?.updateType != 'UpdateRepairAdd' ? true : false,
            ishidden: pageType == 'detail' || locationState?.updateType == 'UpdateRepairAdd' ? false : true,
            dependencies: ['realBeginTime', 'periodNum'],
            rules: [
              ({ getFieldValue }) => ({
                validator(_, value) {
                  if (!getFieldValue('realBeginTime')) {
                    return Promise.resolve();
                  }

                  if (moment(value)?.isBefore(moment(getFieldValue('realBeginTime')))) {
                    return Promise.reject(new Error('合同截止时间不能早于合同签订时间，请修改。'));
                  }
                  return Promise.resolve();
                },
              }),
            ],
          },
          {
            field: `contractInfo`,
            label: `合同简介`,
            component: 'InputTextArea',
            placeholder: pageType == 'detail' ? '--' : '请输入',
            colSpan: 2,
            allowClear: true,
            showCount: true,
            maxLength: 500,
            required: false,
            disabled: pageType == 'detail' ? true : false,
            autoSize: { minRows: 4, maxRows: 8 },
          },

          {
            field: `ownerID`,
            label: `申请人ID`,
            component: 'Input',
            message: '请选择申请人ID',
            placeholder: '请选择',
            disabled: true,
            initialValue: getUserID(),
            colSpan: 2,
            display: 'none',
          },
          {
            field: `ownCompanyID`,
            label: `申请人公司ID`,
            component: 'Input',
            message: '请选择申请人公司ID',
            placeholder: '请选择',
            disabled: true,
            initialValue: getCompanyID(),
            colSpan: 2,
            display: 'none',
          },
          {
            field: `ownCompanyName`,
            label: `申请人公司名称`,
            component: 'Input',
            message: '请选择申请人公司名称',
            placeholder: '请选择',
            disabled: true,
            initialValue: getCompanyName(),
            colSpan: 2,
            display: 'none',
          },
          {
            field: `ownDepartmentID`,
            label: `申请部门ID`,
            component: 'Input',
            message: '请选择申请部门ID',
            placeholder: '请选择',
            disabled: true,
            colSpan: 2,
            initialValue: getUserDepID(),
            display: 'none',
          },
          {
            field: `ownPositionID`,
            label: `申请人岗位ID`,
            component: 'Input',
            message: '请选择申请人岗位ID',
            placeholder: '请选择',
            disabled: true,
            initialValue: getPosIDs(),
            colSpan: 2,
            display: 'none',
          },
          {
            field: `ownPositionName`,
            label: `申请人岗位`,
            component: 'Input',
            message: '请选择申请人岗位',
            placeholder: '请选择',
            disabled: true,
            initialValue: getPosName(),
            colSpan: 2,
            display: 'none',
          },

          {
            field: `createrID`,
            label: `创建人ID`,
            component: 'Input',
            message: '请选择创建人ID',
            placeholder: '请选择',
            disabled: true,
            initialValue: getUserID(),
            colSpan: 2,
            display: 'none',
          },
          {
            field: `createCompanyID`,
            label: `创建人公司ID`,
            component: 'Input',
            message: '请选择创建人公司ID',
            placeholder: '请选择',
            disabled: true,
            initialValue: getCompanyID(),
            colSpan: 2,
            display: 'none',
          },
          {
            field: `createDepartmentID`,
            label: `创建人部门ID`,
            component: 'Input',
            message: '请选择创建人部门ID',
            placeholder: '请选择',
            disabled: true,
            colSpan: 2,
            initialValue: getUserDepID(),
            display: 'none',
          },
          {
            field: `createPositionID`,
            label: `创建人岗位ID`,
            component: 'Input',
            message: '请选择创建人岗位ID',
            placeholder: '请选择',
            disabled: true,
            initialValue: getPosIDs(),
            colSpan: 2,
            display: 'none',
          },

          {
            field: `projectID`,
            label: `资金来源ID`,
            component: 'Input',
            message: '请选择资金来源ID',
            placeholder: '请选择',
            disabled: true,
            colSpan: 2,
            display: 'none',
          },
          {
            field: `budgetFlag`,
            label: `是否超预算`,
            component: 'Select',
            initialValue: '0',
            colSpan: 2,
            display: 'none',
            options: [
              {
                label: '否',
                value: '0',
              },
              {
                label: '是',
                value: '1',
              },
            ],
          },
          {
            field: 'draftCode',
            label: '草案编号',
            component: 'Input',
            placeholder: '请输入',
            disabled: true,
            colSpan: 2,
            initialValue: getUserShortCode(),
            display: 'none',
          },
          {
            field: `pbusinessType`,
            label: `合同类型上级`,
            component: 'Input',
            message: '请选择合同类型上级',
            placeholder: '请选择',
            disabled: true,
            colSpan: 2,
            display: 'none',
          },
          {
            field: `businessTypeName`,
            label: `合同类型名称`,
            component: 'Input',
            message: '请选择合同类型名称',
            placeholder: '请输入',
            disabled: true,
            colSpan: 2,
            display: 'none',
          },
          {
            field: `payStyleName`,
            label: `支付方式名称`,
            component: 'Input',
            message: '支付方式名称',
            placeholder: '请输入',
            disabled: true,
            colSpan: 2,
            display: 'none',
          },
          {
            field: `busiDepartmentName`,
            label: `业务归口部门名称`,
            component: 'Input',
            message: '业务归口部门名称',
            placeholder: '请输入',
            disabled: true,
            colSpan: 2,
            display: 'none',
          },
          {
            field: `relateDepartmentName`,
            label: `相关部门名称`,
            component: 'Input',
            message: '相关部门名称',
            placeholder: '请输入',
            disabled: true,
            colSpan: 2,
            display: 'none',
          },

          {
            field: `sumPaid`,
            label: `已付金额`,
            component: 'InputNumber',
            message: '已付金额',
            placeholder: '已付金额',
            initialValue: 0.0,
            disabled: true,
            colSpan: 2,
            display: 'none',
          },
          {
            field: `workflowType`,
            label: `合同流程`,
            component: 'Input',
            message: '合同流程',
            placeholder: '合同流程',
            initialValue: `${getTenantID()}${ILoadMapTypeAll.CONTRACT_FLOWTYPE}1000`,
            disabled: true,
            colSpan: 2,
            display: 'none',
          },
          {
            field: `state`,
            label: `合同状态`,
            component: 'Select',
            placeholder: '请选择',
            options: loadMapInfo?.[`${getTenantID()}${ILoadMapTypeAll.CONTRACT_STATE}`],
            disabled: true,
            showArrow: false,
            initialValue: contractDetailInfo?.state ? contractDetailInfo?.state : `${getTenantID()}${ILoadMapTypeAll.CONTRACT_STATE}1000`,
            fieldNames: { label: 'name', value: 'id' },
            colSpan: 2,
            display: 'none',
          },
          {
            field: `contactName`,
            label: `合同主体联系人`,
            component: 'Input',
            message: '请选择合同主体联系人',
            placeholder: '请选择',
            disabled: true,
            colSpan: 2,
            display: 'none',
          },
          {
            field: `contacterName`,
            label: `合同联系人`,
            component: 'Input',
            message: '请选择合同联系人',
            placeholder: '请选择',
            disabled: true,
            colSpan: 2,
            display: 'none',
          },
        ],
      },
      {
        key: 'contract-procurement',
        title: '招采信息',
        fieldChildren: [
          {
            field: `purchProjectName`,
            label: `采购项目名称`,
            component: 'Input',
            disabled: true,
            // colSpan: 2,
            message: '请选择',
            placeholder: pageType == 'detail' ? '--' : '请选择',
            contentAfter:
              pageType == 'detail' ? null : (
                <a
                  onClick={() => {
                    openApplyModal(true);
                  }}
                >
                  <SearchOutlined />
                </a>
              ),
            render: (text, record) => {
              if (text) {
                return (
                  <a
                    onClick={() => {
                      enterPurchProject(record);
                    }}
                  >
                    {text}
                  </a>
                );
              } else {
                return <span style={{ color: 'rgba(0, 0, 0, 0.25)' }}>{pageType == 'detail' ? '--' : '请选择'}</span>;
              }
            },
          },
          {
            field: `purchProjectCode`,
            label: `采购项目编号`,
            component: 'Input',
            disabled: true,
            placeholder: pageType == 'detail' ? '--' : '自动带出',
          },
          {
            field: `procureOrg`,
            component: 'Select',
            label: '采购组织类型',
            placeholder: pageType == 'detail' ? '--' : '自动带出',
            required: false,
            showArrow: false,
            disabled: true,
            // initialValue: `${getTenantID()}${ILoadMapTypeAll.PURCHASE_METHOD}1000`,
            options: loadMapInfo?.[`${getTenantID()}${ILoadMapTypeAll.PURCHASE_METHOD}`],
            fieldNames: { label: 'name', value: 'id' },
          },
          {
            field: `procureRealName`,
            label: `采购方式`,
            component: 'Input',
            disabled: true,
            placeholder: pageType == 'detail' ? '--' : '自动带出',
          },
          {
            field: `supplyWay`,
            label: `采购类别`,
            component: 'Select',
            disabled: true,
            placeholder: pageType == 'detail' ? '--' : '自动带出',
            showArrow: false,
            options: [
              { label: '月度计划', value: 0 },
              { label: '零星采购', value: 1 },
              { label: '实验平台', value: 2 },
            ],
          },
          {
            field: `bidTime`,
            label: `中标时间`,
            component: 'DatePicker',
            format: 'YYYY-MM-DD',
            placeholder: pageType == 'detail' ? '--' : '自动带出',
            disabled: true,
          },
          {
            field: `procureReal`,
            label: `采购方式ID`,
            component: 'Input',
            disabled: true,
            placeholder: '自动带出',
            colSpan: 2,
            display: 'none',
          },
          {
            field: `applyID`,
            label: `采购申请ID`,
            component: 'Input',
            message: '请选择采购申请ID',
            placeholder: '请选择',
            disabled: true,
            colSpan: 2,
            display: 'none',
          },
          {
            field: `supplyType`,
            label: `采购类型`,
            component: 'Input',
            message: '请选择采购类型',
            placeholder: '请选择',
            disabled: true,
            colSpan: 2,
            display: 'none',
          },
          {
            field: `supplyTypeName`,
            label: `采购类型名称`,
            component: 'Input',
            message: '请选择采购类型',
            placeholder: '请选择',
            disabled: true,
            colSpan: 2,
            display: 'none',
          },
          {
            field: `sourceID`,
            label: `采购实施ID`,
            component: 'Input',
            message: '请选择采购实施ID',
            placeholder: '请选择',
            disabled: true,
            colSpan: 2,
            display: 'none',
          },
          {
            field: `applyCode`,
            label: `采购申请Code`,
            component: 'Input',
            message: '请选择采购申请Code',
            placeholder: '请选择',
            disabled: true,
            colSpan: 2,
            display: 'none',
          },
          {
            field: `purchaseURL`,
            label: `采购跳转`,
            component: 'Input',
            message: '请选择采购',
            placeholder: '请选择',
            disabled: true,
            colSpan: 2,
            display: 'none',
          },
          {
            field: `sourceCode`,
            label: `采购实施Code`,
            component: 'Input',
            message: '请选择采购实施Code',
            placeholder: '请选择',
            disabled: true,
            colSpan: 2,
            display: 'none',
          },
          {
            field: `applyName`,
            label: `采购申请`,
            component: 'Input',
            message: '请选择采购申请',
            placeholder: '请选择',
            required: false,
            disabled: true,
            colSpan: 2,
            display: 'none',
          },

          // 合同主体信息
          {
            field: `oppositeName`,
            label: `合同主体名称`,
            component: 'Input',
            colSpan: 2,
            // required: pageType == 'detail' ? false : true,
            disabled: true,
            message: '请选择合同主体名称',
            placeholder: '请选择',
            // contentAfter:
            //   pageType == 'detail' ? null : (
            //     <a onClick={openSubjectModal}>
            //       <SearchOutlined />
            //     </a>
            //   ),
            display: 'none',
          },
          {
            field: `creditID`,
            label: `统一社会信用代码`,
            component: 'Input',
            disabled: true,
            placeholder: '自动带出',
            colSpan: 2,
            display: 'none',
          },
          {
            field: `bankName`,
            label: `开户行名称`,
            component: 'Input',
            disabled: true,
            placeholder: '自动带出',
            colSpan: 2,
            display: 'none',
          },
          {
            field: `bankAccount`,
            label: `开户行账号`,
            component: 'Input',
            disabled: true,
            placeholder: '自动带出',
            colSpan: 2,
            display: 'none',
          },
          {
            field: `workAddress`,
            label: `单位地址`,
            component: 'Input',
            disabled: true,
            placeholder: '自动带出',
            colSpan: 2,
            display: 'none',
          },
          {
            field: `registerPhone`,
            label: `单位电话`,
            component: 'Input',
            disabled: true,
            placeholder: '自动带出',
            colSpan: 2,
            display: 'none',
          },
          {
            field: `oppositeID`,
            label: `合同主体ID`,
            component: 'Input',
            message: '请选择合同主体ID',
            placeholder: '请选择',
            disabled: true,
            colSpan: 2,
            display: 'none',
          },
          {
            field: `currencyTypeName`,
            label: `币种名称`,
            component: 'Input',
            message: '请选择币种名称',
            placeholder: '请选择',
            disabled: true,
            colSpan: 2,
            display: 'none',
            initialValue: '人民币',
          },
          {
            field: `procureOrgName`,
            label: `采购组织类型`,
            component: 'Input',
            message: '请选择采购组织类型',
            placeholder: '请选择',
            disabled: true,
            colSpan: 2,
            display: 'none',
          },
        ],
      },
      {
        key: 'contract-partyA',
        title: '合同主体信息',
        fieldCustomDom: <UpdateFirstPartyTableView openSubjectModal={openSubjectModal} />,
      },
      {
        key: 'contract-counterpart',
        title: '相对方信息',
        fieldCustomDom: <UpdateCounterpartView openCounterpartModal={openCounterpartModal} />,
      },
      {
        key: 'contract-payment',
        title: '履约关键节点',
        fieldCustomDom: <UpdatePaymentView formName={contractForm} selectPaymentType={paymentType} />,
      },
      {
        key: 'contract-text',
        title: '合同文本',
        fieldChildren: [
          {
            field: `templateFlag`,
            label: `统一合同范本`,
            component: 'Render',
            loading: mapLoading,
            placeholder: '请选择',
            required: pageType == 'detail' || locationState?.updateType == 'UpdateRepairAdd' ? false : true,
            disabled: pageType == 'detail' || locationState?.updateType == 'UpdateRepairAdd' ? true : false,
            initialValue: 0,
            render: (text, record) => {
              if (pageType == 'detail') {
                return (
                  <Form.Item name="majorFlag" style={{ cursor: 'not-allowed' }}>
                    {renderTableTextNotColor(text)}
                  </Form.Item>
                );
              } else {
                return (
                  <TagSelectNew
                    formLabel=""
                    formName="templateFlag"
                    formRequired={pageType == 'detail' || locationState?.updateType == 'UpdateRepairAdd' ? false : true}
                    radioDisabled={pageType == 'detail' || locationState?.updateType == 'UpdateRepairAdd' ? true : false}
                    radioList={[
                      {
                        value: 1,
                        name: '是',
                        disabled: pageType == 'detail' || locationState?.updateType == 'UpdateRepairAdd' ? true : false,
                      },
                      {
                        value: 0,
                        name: '否',
                        disabled: pageType == 'detail' || locationState?.updateType == 'UpdateRepairAdd' ? true : false,
                      },
                    ]}
                    defalultKeys={text || 0}
                    onChange={(selectKey) => {
                      if (selectKey == 0 && changeTextInfo?.isUnifiedText) {
                        contractForm?.setFieldsValue({
                          templateURL: null,
                          templateID: null,
                          templateType: null,
                        });
                        changeTextInfo?.setIsUnifiedText(false);
                      } else if (selectKey == 1 && !changeTextInfo?.isUnifiedText) {
                        changeTextInfo?.setIsUnifiedText(true);
                      }
                    }}
                  />
                );
              }
            },
          },
          {
            field: `templateURL`,
            label: `合同范本`,
            component: 'Input',
            message: '请选择合同范本',
            placeholder: '请选择',
            required: pageType == 'detail' ? false : true,
            disabled: true,
            ishidden: !changeTextInfo?.isUnifiedText,
            render: (_text, record) => {
              const templatName = record?.templateURL ? getFileNameByPath(record?.templateURL) : '';

              return (
                <div style={{ width: '100%' }}>
                  {templatName ? (
                    <a
                      onClick={() => {
                        // onNtkoReadWord('templateURL', contractDetailInfo, true);
                        onOpenReadOfdWord(record?.templateURL);
                      }}
                    >
                      {templatName}
                    </a>
                  ) : (
                    <span>请选择</span>
                  )}
                </div>
              );
            },
            contentAfter:
              pageType == 'detail' ? (
                <a
                  onClick={() => {
                    // onNtkoReadWord('templateURL', contractDetailInfo, pageType == 'detail' ? true : false);
                    onOpenReadOfdWord(contractDetailInfo?.templateURL);
                  }}
                >
                  <EyeOutlined />
                </a>
              ) : (
                <a
                  onClick={() => {
                    if (contractForm?.getFieldValue('businessType')) {
                      openTempModalFunc(true);
                    } else {
                      message.warning('请先选择合同类型！！！');
                    }
                  }}
                >
                  <SearchOutlined />
                </a>
              ),
          },
          {
            field: `onluEditing`,
            label: `合同正文在线编辑`,
            component: 'Render',
            colSpan: 2,
            disabled: pageType == 'detail' ? true : false,
            ishidden: !changeTextInfo?.isUnifiedText,
            slotRender: () => {
              const contractName = contractForm?.getFieldValue('contractURL') ? getFileNameByPath(contractForm?.getFieldValue('contractURL')) : '';
              /** 相对方列表counterpartRows */
              let params = wordHandChildParamContract({
                ...contractForm?.getFieldsValue(),
                oppositeList: counterpartRows,
              });

              const templateURL = contractForm?.getFieldValue('templateURL') || '';

              return (
                <div style={{ width: '100%', display: 'flex', padding: 10 }}>
                  {contractName && templateURL ? (
                    <>
                      <a>{contractName}</a>
                      <a
                        onClick={() => {
                          onNtkoReadWord('contractURL', params, false);
                        }}
                        style={{
                          marginLeft: 20,
                        }}
                      >
                        <FormOutlined />
                      </a>
                    </>
                  ) : (
                    <span>--</span>
                  )}
                </div>
              );
            },
          },
          {
            field: `contractURL`,
            label: `合同文本`,
            component: 'Render',
            required: pageType == 'detail' ? false : true,
            ishidden: !!changeTextInfo?.isUnifiedText,
            slotRender: (text: any) => {
              if (pageType == 'detail') {
                const contractName = text ? getFileNameByPath(text) : '';
                return (
                  <div style={{ width: '100%', display: 'flex', justifyContent: 'space-between', padding: 10 }}>
                    {contractName ? (
                      <>
                        <a>{contractName}</a>
                        <a
                          onClick={() => {
                            // onNtkoReadWord(contractDetailInfo?.scanURL ? 'scanURL' : 'contractURL', contractDetailInfo, pageType == 'detail' ? true : false);
                            onOpenReadOfdWord(contractDetailInfo?.contractURL);
                          }}
                        >
                          <EyeOutlined />
                        </a>
                      </>
                    ) : (
                      <span>--</span>
                    )}
                  </div>
                );
              } else {
                return (
                  <UploadFormCommon
                    form={config.form}
                    label=""
                    fileFormName={'contractURL'}
                    spanCol={24}
                    inRowProportion={24}
                    name={'attachFile'}
                    required={!changeTextInfo?.isUnifiedText ? true : false}
                    accept={locationState?.updateType != 'UpdateRepairAdd' ? '.docx|.doc' : '.pdf'}
                    url={'/contractController/uploadFile'}
                    downloadUrl={'/contractController/downloadFile'}
                    fileFormDelName={'contractURLDel'}
                    delFunc={() => {}}
                    maxFile={1}
                    defaultFiles={contractDetailInfo && contractDetailInfo?.id ? contractDetailInfo?.contractURL : null}
                    isEdit={true}
                    // disabledUpload={changeTextInfo?.isUnifiedText ? true : false}
                    fieldBusiPath={'contract/info'}
                    onNtkoRead={(wordUrl: string) => {
                      // onNtkoReadWord('contractURL', contractForm?.getFieldsValue(), pageType == 'detail' ? true : false);
                      onOpenReadOfdWord(contractForm?.getFieldValue('contractURL'));
                    }}
                  >
                    上传合同文本
                  </UploadFormCommon>
                );
              }
            },
          },
          {
            field: `contractURL`,
            label: `范本地址（合同原文地址）`,
            component: 'Input',
            message: '请选择范本地址（合同原文地址）',
            placeholder: '请选择',
            disabled: true,
            colSpan: 2,
            ishidden: !changeTextInfo?.isUnifiedText,
            display: 'none',
          },
          {
            field: `templateType`,
            label: `范本类型`,
            component: 'Input',
            message: '请选择范本类型',
            placeholder: '请选择',
            disabled: true,
            colSpan: 2,
            display: 'none',
          },
          {
            field: `templateID`,
            label: `范本ID`,
            component: 'Input',
            message: '请选择范本ID',
            placeholder: '请选择',
            disabled: true,
            colSpan: 2,
            display: 'none',
          },
        ],
      },
      {
        key: 'contract-moneyCopy',
        title: (
          <span>
            货物/服务清单{' '}
            <p
              style={{ fontSize: 16, fontWeight: 400, color: 'red', margin: 0 }}
            >{`(提示：填写货物清单，请点击【选择】按钮，从物料库中选择录入；填写服务或工程清单，请点击【添加行】按钮，手动录入。)`}</p>
          </span>
        ),
        fieldCustomDom: <UpdateMaterialTableView setOpenMaterialModal={setOpenMaterialModal} loadMapInfo={loadMapInfo} formName={contractForm} />,
      },
      {
        key: 'contract-annexFiel',
        title: (
          <>
            相关附件 &nbsp;
            <Tooltip title="授权代表人签署的合同需提供法定代表人授权委托书">
              <a>
                <QuestionCircleOutlined />
              </a>
            </Tooltip>
          </>
        ),
        fieldCustomDom: <UpdateFiledTableView formName={contractForm} loadMapInfo={loadMapInfo} onFormChange={onFormChange} />,
      },
    ],
  });
  return {
    config,
    methods,
    loadMapInfo,
  };
};

export { getDescrConfig };
